package main

import (
	realrand "crypto/rand"
	"fmt"
	"math/big"
	"math/rand"
)

func main() {
	for i := 0; i < 100; i++ {
		fmt.Println(GetRand())
	}
	fmt.Println("+++++++++++++++++++++++++++++++++++++++++++++++++")
	for i := 0; i < 100; i++ {
		fmt.Println(GetRand1(10))
	}
	fmt.Println("+++++++++++++++++++++++++++++++++++++++++++++++++")
	for i := 0; i < 100; i++ {
		fmt.Println(GetRealRand())
	}
}

//1 利用golang 自带random 包

func GetRand() int {
	return rand.Int()
}

func GetRand1(n int) int {
	return rand.Intn(n)
}

func GetRealRand() *big.Int {
	result, _ := realrand.Int(realrand.Reader, big.NewInt(100))
	return result
}
